package com.xqboss.apps.mapper.guild;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xqboss.apps.domain.guild.GuildInviteRecord;
import com.xqboss.apps.vo.guild.GuildInviteMeRecordVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;


/**
 * 公会邀请记录表——会长操作(GuildInviteRecord)表数据库访问层
 *
 * @author ljh
 * @since 2024-01-09 17:21:10
 */
@Repository
public interface GuildInviteRecordMapper extends BaseMapper<GuildInviteRecord> {

    /**
     * 获取邀请我的公会记录
     *
     * @param userId 被邀请的用户id
     * @return 邀请我的
     */
    IPage<GuildInviteMeRecordVo> getInviteMeRecordVo(Page<GuildInviteMeRecordVo> page, @Param("invitedUserId") Long userId);

    /**
     * 获取指定公会、指定用户、指定状态的邀请记录数量
     *
     * @param guildId 公会id
     * @param userId 邀请用户id
     * @param value 邀请状态
     * @return
     */
    @Select("select count(1) from guild_invite_record where invite_guild_id = #{guildId} and invited_user_id = #{userId} and invite_status = #{value} and del_flag = 0")
    int countInviteRecord(@Param("guildId") Long guildId,@Param("userId") Long userId,@Param("value") Integer value);
}

